<%@ page language="java" pageEncoding="utf-8"%>
<%@taglib prefix="s" uri="/struts-tags"%>
${aier_doctype}
<html <s:property value="aier_html_xmlns" escape="false"/>>
<head>
<meta http-equiv="Content-Type" content="${aier_content_type}" />
<title><s:property value="ev_title" /></title>
<meta name="keywords" content="${aier_keyworks}" />
<meta name="description" content="${aier_description}" />
<link href="${aier_css_url}jq/jq.css" rel="Stylesheet" />
<link rel="stylesheet" href="${aier_css_url}${aier_jqui_css}/ui.css" />
<link rel="stylesheet" href="${aier_css_url}social/module/jq-msg.css" />
<link rel="stylesheet" href="${aier_css_url}comm/text.css" />
<link rel="stylesheet" href="${aier_css_url}admin/admin.css" />

<script type="text/javascript" src="${aier_js_url}j.js"></script>
<script type="text/javascript" src="${aier_js_url}b.js"></script>
<script type="text/javascript" src="${aier_js_url}jp/msg.js"></script>
<script type="text/javascript" src="${aier_js_url}jp/1.js"></script>
<script type="text/javascript" src="${aier_js_url}lib/afu.js"></script>
<script type="text/javascript" src="${aier_js_url}jp/hh/ui.js"></script>
<script type="text/javascript" src="${aier_js_url}lib/block.js"></script>
<script type="text/javascript" src="${aier_js_url}lib/arrayList.js"></script>
<script type="text/javascript" src="${aier_js_url}jc/cj.js"></script>
<script type="text/javascript" src="${aier_js_url}jq/jq.js"></script>
<script type="text/javascript" src="${aier_js_url}jq/cn.js"></script>
<script type="text/javascript" src="${aier_js_url}comm/text.js"></script>
</head>
<script type="text/javascript">
$(document).ready(function(){
    $("#proxyinfo").jqGrid({                
        url:'${aier_url}${aier_urijs}adminproxy_searchProxy${aier_suffix}',                
        datatype:"json",                
        mtype:'GET',
        height:'230',
        width:'960',              
        colNames:['代理商帐号','代理商名称','联系邮件','联系电话','详细信息','分派卡','pid'],                
        colModel:[                    
        {name:'account',index:'account',width:80,align:'center'},                    
        {name:'name',index:'name',width:100,align:'center'},
        {name:'email',index:'email',width:100,align:'center'},
        {name:'phone',index:'phone',width:120,align:'center'},
        {name:'revoked',index:'revoked',width:80,align:'center'},
        {name:'revoked1',index:'revoked1',width:80,align:'center'},
        {name:'pid',index:'pid',hidden : true}
        ],
        //autowidth:true,
        jsonReader: {
            root:"proxies",
            page: "page",
            total: "page_count",
            records : "count",
            repeatitems: false
        },
        pager: jQuery("#proxypage"),
        prmNames : {page:"page",sort: "sort"},
        rowNum: 10,
        //rowList: [10, 20, 30],
        sortname: 'pid',
        hidegrid: false,
        sortorder: 'asc',
        viewrecords: true,
        caption: '代理商管理',
        gridComplete:function(){
            var ids=jQuery("#proxyinfo").jqGrid('getDataIDs');
            for(var i=0; i<ids.length; i++){
                var id=ids[i]; 
                var re = "<a href='javascript:;' class='jqtrow' onclick='showInfo(" + id + ")'>详细信息</a>";
                var re1 = "<a href='javascript:;' class='jqtrow' onclick='assign(" + id + ")'>分派卡</a>";
                jQuery("#proxyinfo").jqGrid('setRowData', ids[i], { revoked: re, revoked1: re1});
            }
        }
    }).navGrid("#proxypage", { edit: false, add: false, del: false, search: false });
}); 
</script>
<body style="background-color: #EEF2FB;">
    
    <div style="background-color: #EEF2FB;width: 100%;height: 700px; ">
       
         <div id="tabs">
             <ul>
                 <li><a href="#tabs-1">代理商管理</a></li>
             </ul>
             <div id="tabs-1" style="height: 500px;">
                 <div class="d_content">
                    <div class="d_scnOut">
                        <div class="d_scname">
                            <label for="name">管理区域:</label>
                        </div>
                        <div class="sel_region">
                            <s:action name="cityutil" namespace="/common"
                                executeResult="true">
                                <s:param name="cityid">-1</s:param>
                            </s:action>
                        </div>
                    </div>
                    <div class="d_scnOut">
                        <div class="d_scname" style="margin-left: 0px;">
                            <label for="name">帐号: </label>
                        </div>
                        <div class="d_sctext">
                            <input type="text" id="saccount" />
                        </div>
                    </div>
                    <div class="d_scnOut" style="margin-left: 280px;margin-top: -40px;">
                        <div class="d_scname" style="margin-left: 0px;">
                            <label for="name">名称: </label>
                        </div>
                        <div class="d_sctext">
                            <input type="text" id="sname" />
                        </div>
                    </div>
                    <div style="margin-left: 600px;margin-top: -47px;">
                        <button onclick="search();"
                            class="ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only"
                            role="button" aria-disabled="false">
                            <span class="ui-button-text">查询</span>
                        </button>
    
                    </div>
                    
                    <button onclick="create()" style="margin-left: 860px;"
	                    class="b_maSel ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only"
	                    role="button" aria-disabled="false">
	                    <span class="ui-button-text">新建</span>
	                </button>
                     <!-- 表格 -->
                     <div style="margin-left: 0px;margin-top: 0px;">
                         <table id="proxyinfo"></table>
                         <div id="proxypage"></div>
                     </div>
                            
				</div>
			</div>
        </div>
	</div>

	<script type="text/javascript">
	   $("#tabs").tabs();
	   var cidStr;
	   
       // 创建代理商
	   function create() {
	       window.location.href = "${aier_url}${aier_uri}/proxy_create${aier_suffix}";
	   }
	   // 显示详细信息
	   function showInfo(id) {
	       var pid = jQuery("#proxyinfo").jqGrid('getRowData', id).pid;
	       window.location.href = "${aier_url}${aier_uri}/proxy_detail${aier_suffix}?pid="+pid;
	    }
	    
      function search(){
         var pcid = -1;
         if(acity.cid>-1){
            pcid = acity.cid;
         }
         jQuery("#proxyinfo").jqGrid('setGridParam',{url:'${aier_url}${aier_urijs}adminproxy_searchProxy${aier_suffix}'+"?cid="+pcid+"&proxyName="+$("#sname").val()+"&account="+$("#saccount").val(),page:1}).trigger("reloadGrid");
     }
     // 分派卡
     function assign(id) {
         var account = jQuery("#proxyinfo").jqGrid('getRowData', id).account;
         window.location.href = "${aier_url}${aier_uri}/assign_card${aier_suffix}?account="+account;
     }
	</script>
</body>
</html>